Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

386
Visualizações
Error: Error serializing `propertiesForSale` returned from `getStaticProps` in "/". Reason: `undefined` cannot be serialized as JSON

I am trying to fetch data from the Zillow API through RapidApi. I am new to NextJS.

Here is the code from my index.js:

export async function getStaticProps() {
  const propertyForSale = await fetchApi(`${baseUrl}/propertyExtendedSearch/list?location=Texas&purpose=for-sale&hitsPerPage=6`)
  const propertyForRent = await fetchApi(`${baseUrl}/propertyExtendedSearch/list?location=Texas&purpose=for-rent&hitsPerPage=6`)

  return {
    props: {
      propertiesForSale: propertyForSale?.hits,
      propertiesForRent: propertyForRent?.hits,
    }
  }
}

Here is the code from my fetchApi.js:


export const baseUrl = 'https://zillow-com1.p.rapidapi.com'

export const fetchApi = async (url) => {
    const { data } = await axios.get ((url), {
        headers: {
            'x-rapidapi-host': 'zillow-com1.p.rapidapi.com',
            'x-rapidapi-key': '8e2e11ca6dmsh77a061b9b854a4ep1762d7jsne6e273637c9f'
        }
    })
    return data;
}
about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

I ran through your request through postman and it does not return any results

curl --location --request GET 'https://zillow-com1.p.rapidapi.com/propertyExtendedSearch/list?location=Texas%26purpose=for-sale%26hitsPerPage=6' \
--header 'x-rapidapi-host: zillow-com1.p.rapidapi.com' \
--header 'x-rapidapi-key: 8e2e11ca6dmsh77a061b9b854a4ep1762d7jsne6e273637c9f'

It returns

{
    "status": "error",
    "statusMessage": "Endpoint no found! Check your query URL and parameters!"
}

Check your get request outside of code and re-post the question. For stability of the solution and if the API offers the status node consistently you should check for success before proceeding to access other values.

about 4 years ago · Juan Pablo Isaza Relatório

0

//change the ?. hit to ?.data just the way i did it below

export async function getStaticProps() { const propertyForSale = await fetchApi(${baseUrl}/propertyExtendedSearch/list?location=Texas&purpose=for-sale&hitsPerPage=6) const propertyForRent = await fetchApi(${baseUrl}/propertyExtendedSearch/list?location=Texas&purpose=for-rent&hitsPerPage=6)

return { props: { propertiesForSale: propertyForSale?.data, propertiesForRent: propertyForRent?.data, } } }

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda